package com.linln.modules.system.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.component.excel.annotation.Excel;
import com.linln.component.excel.enums.ExcelType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;


@Data
@Entity
@Table(name = "pcs_pay_record")
@ToString(exclude = {"dept", "roles"})
@EqualsAndHashCode(exclude = {"dept", "roles"})
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update pcs_pay_record" + StatusUtil.SLICE_DELETE)
@Where(clause = StatusUtil.NOT_DELETE)
@Excel("支付退款记录")
public class PayRecord implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Excel(value = "ID", type = ExcelType.EXPORT)
    private Long id;

    @CreatedDate
    @Excel("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    @LastModifiedDate
    @Excel("更新时间")
    private Date updateTime;

    @JsonIgnore
    private Long createUser;

    @JsonIgnore
    private Long updateUser;

    @JsonIgnore
    private Byte status = StatusEnum.OK.getCode();

    private String companyId;

    private String orderNo;

    @Excel("子订单号")
    private String orderChildNo; // 新增字段

    private String msg;

    private String result;

    private String patientName;

    @Excel("预退款状态 0失败 1成功")
    private Integer outStatus;

    @Excel("退款类型 1手动取消订单 2到时间自动取消订单 3患者结束陪护 4手动点击服务完成 5余额不足终止订单")
    private Integer type;

    @Excel("退款订单号")
    private String outRefundNo;

    @Excel("退款金额")
    private String outRefundFee;

    @Excel("退款回调状态 0失败 1成功 2退款中")
    private Integer backStatus;

    private String remark;

    @Excel("操作类型 1支付 2退款")
    private Integer operatorStatus;

    @Excel("支付金额")
    private String payFee;


    @Excel("支付状态 0失败 1成功")
    private Integer payStatus;

    @Excel("支付回调状态 0失败 1成功 2支付中")
    private Integer payBackStatus;

    private String payRemark;

}
